<?php

namespace App\Http\Controllers\Common;

use App\Http\Classes\Sentence;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class SentenceController extends Controller
{
    /*
    * 获取某一课程下的所有句子
    * GET
    * lesson(int)
    */
    public function getSentencesByLesson(Request $request)
    {
        try
        {
            if ( $request->has('lesson') )
            {
                $lesson = $request->get('lesson');

                $sentence = new Sentence();
                $sentences = $sentence->getSentencesByLessonId($lesson);

                if ( $sentences )
                {
                    return $this->response(1, '获取成功', $sentences);
                }
                else
                {
                    return $this->response(0, '无匹配数据', null, $sentence->getMessage());
                }
            }
            else
            {
                return $this->response(0, '缺省参数', null);
            }
        }
        catch (\Exception $exception)
        {
            return $this->exceptionResponse($exception, __FUNCTION__);
        }
    }
}
